﻿#ifndef UPAGINATION_H
#define UPAGINATION_H

#include "utkwidget_export.h"

#include <QWidget>

class UPaginationPrivate;
class UTKWIDGET_EXPORT UPagination : public QWidget
{
    Q_OBJECT
public:
    explicit UPagination(QWidget* parent = nullptr);

    explicit UPagination(int maxPage, QWidget* parent = nullptr);

    ~UPagination();

    void setButtonSize(const QSize &size);

    int maxPage() const;

    int currentPage() const;

    // 其他组件只需要调用这两个函数即可
    void setMaxPage(int maxPage);   // 当总页数改变时调用

    void setCurrentPage(int currentPage); // 修改当前页时调用

private:
    void updatePage();

signals:
    void currentChange(int page);

public slots:
    void buttonClicked(int index);

private:
    QScopedPointer<UPaginationPrivate> d_ptr;
    Q_DISABLE_COPY(UPagination)
    Q_DECLARE_PRIVATE_D(d_ptr, UPagination)
};

#endif // UPAGINATION_H
